/*
组件数据懒加载
const target = ref<any>(null)
const { stop } = useIntersectionObserver(target, ([{ isIntersecting }]) => {
  if (isIntersecting) {
    homeStore.getNewGoodList()
    stop()
  }
}) */
import { useIntersectionObserver } from '@vueuse/core'
import { ref } from 'vue'

export function uselazy(fn: any) {
  const target = <any>ref(null)
  const { stop } = useIntersectionObserver(target, ([{ isIntersecting }]) => {
    if (isIntersecting) {
      fn() //fn是一个要调用的方法
      stop()
    }
  })
  return target //就是空的ref对象要和组件内的那个dom进行绑定
}
